﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tools.Resource {
    public class Configer {

        public const string Version = "6.1.8";

        public static readonly string UserAgent = GetUa();

        #region 帐户信息
        /// <summary>
        /// 七牛提供的公钥，用于识别用户
        /// </summary>
        //public static string ACCESS_KEY = "<Please apply your access key>";
        public static string AccessKey = "SUP3lg692N7YEIz3BE6G9Ahk33RLmtduokGNkWAv";
        /// <summary>
        /// 七牛提供的秘钥，不要在客户端初始化该变量
        /// </summary>
        //public static string SECRET_KEY = "<Dont send your secret key to anyone>";
        public static string SecretKey = "HV_fG1BjEr9V8L2_mGNpNc4DhKKRUxMXUaZpCt_W";

        #endregion

        #region 七牛服务器地址

        /// <summary>
        /// 资源[管理]服务器地址
        /// </summary>
        public static string RsHost = "http://rs.Qbox.me";

        /// <summary>
        /// 资源[上传]服务器地址.
        /// </summary>
        public static string UpHost = "http://up.qiniu.com";

        /// <summary>
        /// 资源[列表]服务器地址.
        /// </summary>
        public static string RsfHost = "http://rsf.Qbox.me";

        public static string PrefetchHost = "http://iovip.qbox.me";

        public static string ApiHost = "http://api.qiniu.com";

        #endregion
        /// <summary>
        /// 七牛SDK对所有的字节编码采用utf-8形式 .
        /// </summary>
        public static Encoding Encoding = Encoding.UTF8;

        /// <summary>
        /// 初始化七牛帐户、请求地址等信息，不应在客户端调用
        /// TODO：初始化标准是什么
        /// </summary>
        public static void Init() {
            //if (System.Configuration.ConfigurationManager.AppSettings["USER_AGENT"] != null) {
            //    UserAgent = System.Configuration.ConfigurationManager.AppSettings["USER_AGENT"];
            //}
            //if (System.Configuration.ConfigurationManager.AppSettings["ACCESS_KEY"] != null) {
            //    AccessKey = System.Configuration.ConfigurationManager.AppSettings["ACCESS_KEY"];
            //}
            //if (System.Configuration.ConfigurationManager.AppSettings["SECRET_KEY"] != null) {
            //    SecretKey = System.Configuration.ConfigurationManager.AppSettings["SECRET_KEY"];
            //}
            //if (System.Configuration.ConfigurationManager.AppSettings["RS_HOST"] != null) {
            //    RsHost = System.Configuration.ConfigurationManager.AppSettings["RS_HOST"];
            //}
            //if (System.Configuration.ConfigurationManager.AppSettings["UP_HOST"] != null) {
            //    UpHost = System.Configuration.ConfigurationManager.AppSettings["UP_HOST"];
            //}
            //if (System.Configuration.ConfigurationManager.AppSettings["RSF_HOST"] != null) {
            //    RsfHost = System.Configuration.ConfigurationManager.AppSettings["RSF_HOST"];
            //}
            //if (System.Configuration.ConfigurationManager.AppSettings["PREFETCH_HOST"] != null) {
            //    PrefetchHost = System.Configuration.ConfigurationManager.AppSettings["PREFETCH_HOST"];
            //}
        }

        /// <summary>
        /// TODO:为什么需要访问类库版本号
        /// </summary>
        /// <returns></returns>
        private static string GetUa() {
            return "QiniuCsharp/" + Version + " (" + Environment.OSVersion.Version.ToString() + "; )";
        }
    }
}
